In [4]:
import escher
import escher.urls
import cobra
import cobra.test
import json
import os
from IPython.display import HTML

In [5]:
d = escher.urls.root_directory
print('Escher directory: %s' % d)


Escher directory: /Users/zaking/repos/escher

Embed an Escher map in an IPython notebook


In [6]:
escher.list_available_maps()


Out[6]:
[{'map_name': 'e_coli_core.Core metabolism', 'organism': 'Escherichia coli'},
 {'map_name': 'iJO1366.Central metabolism', 'organism': 'Escherichia coli'},
 {'map_name': 'iJO1366.Fatty acid beta-oxidation',
  'organism': 'Escherichia coli'},
 {'map_name': 'iJO1366.Fatty acid biosynthesis (saturated)',
  'organism': 'Escherichia coli'},
 {'map_name': 'iJO1366.Nucleotide metabolism', 'organism': 'Escherichia coli'},
 {'map_name': 'RECON1.Amino acid metabolism (partial)',
  'organism': 'Homo sapiens'},
 {'map_name': 'RECON1.Carbohydrate metabolism', 'organism': 'Homo sapiens'},
 {'map_name': 'RECON1.Glycolysis TCA PPP', 'organism': 'Homo sapiens'},
 {'map_name': 'RECON1.Inositol retinol metabolism',
  'organism': 'Homo sapiens'},
 {'map_name': 'RECON1.Tryptophan metabolism', 'organism': 'Homo sapiens'},
 {'map_name': 'iMM904.Central carbon metabolism',
  'organism': 'Saccharomyces cerevisiae'}]

In [7]:
b = escher.Builder(map_name='e_coli_core.Core metabolism')
b.display_in_notebook()


/Users/zaking/repos/escher/escher/plots.py:152 UserWarning: Map not in cache. Attempting download from https://escher.github.io/1-0-0/2/maps/Escherichia%20coli/e_coli_core.Core%20metabolism.json
Out[7]:

Plot FBA solutions in Escher


In [9]:
model = cobra.io.json.from_json(escher.plots.model_json_for_name('e_coli_core'))
solution = model.optimize()
print('Growth rate: %.2f' % solution.f)


Growth rate: 0.87

In [10]:
b = escher.Builder(map_name='e_coli_core.Core metabolism',
                   reaction_data=solution.x_dict,
                   # color and size according to the absolute value
                   reaction_styles=['color', 'size', 'abs', 'text'],
                   # change the default colors
                   reaction_scale=[{'type': 'min', 'color': '#cccccc', 'size': 4},
                                   {'type': 'mean', 'color': '#0000dd', 'size': 20},
                                   {'type': 'max', 'color': '#ff0000', 'size': 40}],
                   # only show the primary metabolites
                   hide_secondary_metabolites=True)
b.display_in_notebook()


Out[10]:

Use a COBRA model from the IPython Notebook to edit maps


In [11]:
model_modified = model.copy()
# for example, delete a reaction
model_modified.reactions.GAPD.delete()

In [12]:
# pass the model to a new builder
b = escher.Builder(map_name='e_coli_core.Core metabolism',
                   model=model_modified,
                   # in the map, highlight all reactions that are missing from the model
                   highlight_missing=True)
b.display_in_notebook()


Out[12]:

In [ ]:
# open the Builder in a new tab to edit this map with your modified model
b.display_in_browser()

In [ ]: